//引入vue-router
import VueRouter from "vue-router"
//引入组件
import videoUpload from "@/views/videoUpload/index.vue"
import h5 from "@/views/h5/index.vue"
import login from "@/views/login/index.vue";
import videoUploadH5 from "@/views/videoUploadH5/index.vue";
import videoMineH5 from "@/views/videoMineH5"
import notFindPage from "@/components/404.vue"
import videoDetailH5 from "@/views/videoDetailH5/index.vue";


//防止报错：Navigation aborted from "/videoUpload" to "/login" via a navigation guard.
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location, onResolve, onReject) {
    if (onResolve || onReject) {
        return originalPush.call(this, location, onResolve, onReject)
    }
    return originalPush.call(this, location).catch(err => err)
}

//路由规则
const routes = [// 重定向到一级路由Home
    {
        path: '/', redirect: '/videoUpload'
    }, {
        path: '/videoUpload', component: videoUpload, meta: {
            title: '双英口语-上传作品',
        }
    }, {
        path: '/h5', component: h5, meta: {
            title: '双英口语-比赛报名表',
        }
    }, {
        path: '/login', component: login, meta: {
            title: '双英口语-登录',
        }
    }, {
        name: 'videoH5', path: '/videoH5', component: videoUploadH5, meta: {
            title: '双英口语-上传作品',
        }
    }, {
        path: '/videoMineH5', component: videoMineH5, meta: {
            title: '双英口语-我的作品',
        }
    }, {
        name: 'detailH5', path: '/videoDetailH5', component: videoDetailH5, meta: {
            title: '双英口语-作品详情',
        }
    }, {
        path: '/notFindPage', component: notFindPage, meta: {
            title: '双英口语-页面丢失404',
        }
    }

]
//创建路由对象
const router = new VueRouter({
    mode: 'hash',// 模式:1、history模式，去除url里的“#” （会存在刷新找不到文件的情况） 2、hash模式
    routes
})


//对外暴露路由
export default router
